package SlotGame

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/types"
	"gitee.com/liuxuezhan/ar-platform/base-common/tool/wlog"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"
	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type SlotGameHistoryLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 玩家历史记录
func NewSlotGameHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SlotGameHistoryLogic {
	return &SlotGameHistoryLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SlotGameHistoryLogic) SlotGameHistory(req *types.SlotGameHistoryReq) (resp *types.SlotGameHistoryRes, err error) {
	// UserId := headInfo.GetTokenUid(l.ctx)
	// if UserId == 0 {
	// 	return nil, xerrors.UserTokenInvalid
	// }
	rpc_req := &rpc.SlotGameHistoryReq{}
	copier.Copy(rpc_req, req)
	// 发送请求
	rpc_resp, err := l.svcCtx.AssetsRpc.RpcSlotGame.SlotGameHistory(l.ctx, rpc_req)
	if err != nil {
		wlog.Handle.Errorf(l.ctx, "Call ModifyVipLevelInfos error: %v", err)
		return nil, err
	}
	// 处理请求返回的结果
	// 解析、组合数据
	resp = &types.SlotGameHistoryRes{}
	copier.Copy(resp, rpc_resp)
	return
}
